"""author: wenyao
   data: 2020/10/21
   project: ludingji
"""
#周五的时候做个打字测试   英文单词每分钟100以上
#金山打字通
#################列表的定义###########################
# >>> lst = []
# >>> type(lst)
# <class 'list'>
# >>> lst2 = list()
# >>> type(lst)
# <class 'list'>
# >>> type(lst2)
# <class 'list'>
# >>> lst3 = list("abc")
# >>> lst3
# ['a', 'b', 'c']

############python 一切皆对象###################

###索引 切片#######
#下标不能越界
# >>> lst
# ['b', 2, 3, 4]
# >>> lst[4]
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# IndexError: list index out of range

# >>> a[-3:4:-1]
# []
# >>> a[2:-2]
# [3, 4]
# >>> a
# [1, 2, 3, 4, 5, 6]
# >>> a[1:-3]
# [2, 3]
# >>> a[-5:-2]
# [2, 3, 4]
# >>> a[::-1]
# [6, 5, 4, 3, 2, 1]
# >>> str[::-1]
# '654321'
# >>> a = [1,2,3,4,5,6,7,8,9,0]
# >>> a[::2]
# [1, 3, 5, 7, 9]

#=======================列表的基本操作==============
#增加-append
# >>> lst
# ['apple', 'orange', 123, 0.111, 'cali']
# >>> lst.append("test")
# >>> lst
# ['apple', 'orange', 123, 0.111, 'cali', 'test']
# >>> lst1 = [1,2,3]
# >>> lst.append(lst1)
# >>> lst
# ['apple', 'orange', 123, 0.111, 'cali', 'test', [1, 2, 3]]

########增加-insert
#指定位置添加
# >>> lst
# ['apple', 'orange', 123, 0.111, 'cali', 'test', [1, 2, 3]]
# >>> lst.insert(1,'hello')
# >>> lst
# ['apple', 'hello', 'orange', 123, 0.111, 'cali', 'test', [1, 2, 3]]

##增加 -- extend
# >>> lst1
# [1, 2, 3]
# >>> lst.extend(lst1)
# >>> lst
# ['apple', 'hello', 'orange', 123, 0.111, 'cali', 'test', [1, 2, 3], 1, 2, 3]
# >>> a = [1,2,3]
# >>> str = "abc"
# >>> a.extend(str)
# >>> a
# [1, 2, 3, 'a', 'b', 'c']

#删除-pop  默认删除最后一个，也可以指定下标删除
# >>> a
# [1, 2, 3, 'a', 'b', 'c', '4', '6', '7', '5']
# >>> a.pop()
# '5'
# >>> a
# [1, 2, 3, 'a', 'b', 'c', '4', '6', '7']
# >>> a.pop(2)
# 3
# >>> a
# [1, 2, 'a', 'b', 'c', '4', '6', '7']
# >>> a.pop(8)
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# IndexError: pop index out of range

#删除  - remove  按照指定元素删除， 删除列表中匹配的第一个元素，如果列表中没有指定元素，就会报错
# >>> a.remove("b")
# >>> a
# [1, 2, 'a', 'c', '4', '6', '7']
# >>> a = ["xx","yy","xx"]
# >>> a.remove("xx")
# >>> a
# ['yy', 'xx']
# >>> a.remove("zz")
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# ValueError: list.remove(x): x not in list

#删除-del
# >>> del a[3]
# >>> a
# [1, 2, 3, 'yy', 'zz']
# >>> del a[0:2]
# >>> a
# [3, 'yy', 'zz']

#删除-clear  清空列表
# >>> a
# [3, 'yy', 'zz']
# >>> a.clear()
# >>> a
# []

#修改
#修改元素主要是利用下标和切片来修改或增加、删除
#利用切片修改，如果切片得到的lst为空，则在start位置开始插入相应的list值
#如果切片得到的lst不为空，则替换查找出来的lst元素。
# >>> a
# [1, 2, 3, 'a', 'b', 'c']
# >>> a[2] = "x"
# >>> a
# [1, 2, 'x', 'a', 'b', 'c']
# >>> a[1:1]
# []
# >>> a[1:1] = "abc"
# >>> a
# [1, 'a', 'b', 'c', 2, 'x', 'a', 'b', 'c']
# >>> b
# ['a', 'b', 'x', 'y', 'z', 'c']
# >>> b[1:5]="12"
# >>> b
# ['a', '1', '2', 'c']

#反转-- reverse 或者是负切片
# >>> a
# [1, 2, 3, 4]
# >>> a[::-1]
# [4, 3, 2, 1]
# >>> a
# [1, 2, 3, 4]
# >>> a.reverse()
# >>> a
# [4, 3, 2, 1]

#排序----sort
#排序的列表里的数据类型需要一致
# >>> a
# [4, 3, 2, 1]
# >>> a.sort()
# >>> a
# [1, 2, 3, 4]
# >>> help(a.sort)
#
# >>> a
# [1, 2, 3, 4]
# >>> a.sort(reverse=True)  #反向排序
# >>> a
# [4, 3, 2, 1]

#统计 --- len、count、index
# >>> len(a)
# 7
# >>> a
# ['a', 'b', '中', '序', '排', '文', [1, 2, 3]]
# >>> a.extend([1,2,3])
# >>> len(a)
# 10
# >>> a
# ['a', 'b', '中', '序', '排', '文', [1, 2, 3], 1, 2, 3]
# >>> a.count("a")
# 1
# >>> a.count(1)
# 1
# >>> a = ["x","y","x",1]
# >>> a.count("x")
# 2
# >>> a.index("x")
# 0
# >>> a.index("z")
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# ValueError: 'z' is not in list

# 列表基本操作-遍历列表
# • 遍历：依次取出对象中的每一项数据
# • list是一个可迭代对象（iterable），可以直接用for遍历

#######################################
#lst = [3,2,7,5,9]
#target = 9
#2+7 =9
#返回[1,2]

# lst = [3,2,6,5,9]
# target = 9
# for i,j in enumerate(lst) :
#     for k,l in enumerate(lst[i+1:]) :
#         while j+l == 9:
#             print(i,k+i)
#             break

# lst = [3,2,7,5,8,1]
# target = 9
# # j = 1
# for i in range(len(lst)):
#     # if j > i :
#         for j in range(len(lst[i+1:])):
#             if lst[i] + lst[j+i+1] == target:
#                 print(f"{i} {j+i+1}")

lst = [3,2,6,5,9]
target = 9
for index, value in enumerate(lst):
    if target - value in lst[index+1:]:
        print(index, lst.index(target-value))



